package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.domain.entity.FormConfigEntity;

import java.util.List;
import java.util.Map;

/**
 * @description: 公告
 * @Author: hongxiao
 * @date: 2019-03-25 14:10
 * @since v1.0
 */
public interface FormConfigModel extends IModel<FormConfigEntity> {

    Integer deleteByKey(Long key, String corpid);

    Integer deleteBatch(List<Long> idIn, String corpid);

    FormConfigEntity getByKey(Long key, String corpid);

    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return 符合查询条件的记录
     */
    @Override
    List<FormConfigEntity> findEntitys(Map<String, Object> param);

    /**
     * 批量插入实体
     * @param list
     * @return 返回数据的列表
     */
    List<FormConfigEntity> insertBatch(List<FormConfigEntity> list);

    /**
     * @description  插入查重的formConfig
     * @author yanglei
     * @date 2022/11/14 15:43
     * @param corpid
     * @param menuId
     * @param config
     * @param businessType
     */
    void insertRepeatType(String corpid, Long menuId, String config, Integer businessType) ;
    /**
     * @description  更新查重的formConfig
     * @author yanglei
     * @date 2022/11/14 15:44
     * @param corpid
     * @param config
     * @param repeatType

     */
    void updateAllRepeatType(String corpid, String config, String repeatType);

    Integer save(FormConfigEntity entity) throws XbbException;

    /**
     * Description: 根据formId获取配置(多模板的业务使用这个才能唯一定位)
     * @param corpid
     * @param formId
     * @param config
     * @see com.xbongbong.saas.enums.FormConfigEnum
     * @return com.xbongbong.pro.domain.entity.FormConfigEntity
     * @author 魏荣杰
     * @date 2019/5/27 15:01
     * @since v1.0
     */
    FormConfigEntity getEntityByFormId(String corpid, Long formId, String config);
    /**
     * 根据formId获取多个按钮配置
     * @param corpid
     * @param formId
     * @param configList
     * @return
     */
    List<FormConfigEntity> getButtonEntityByFormId(String corpid, Long formId, List<String> configList);

    /**
     * Description: 根据 businessType 获取配置(不为多模板的业务可以使用,多模板不要用)
     * @param corpid
     * @param businessType
     * @param config
     * @return com.xbongbong.pro.domain.entity.FormConfigEntity
     * @author 魏荣杰
     * @date 2019/5/27 15:35
     * @since v1.0
     */
    FormConfigEntity getEntityByBusinessType(String corpid, Integer businessType, String config);

    void updateBatch(List<FormConfigEntity> list, String corpid);

    /**
     * 更新表单模板的查重配置
     * @author xingxing.xiao
     * @param param
     * @return
     */
    Integer updateRepeatType(Map<String, Object> param);

    /**
     *
     * @param corpid
     * @param config
     * @param positiveNumber
     * @return
     * @throws XbbException
     * @author jyh
     * @date 2019/12/30 10:20
     * @since v1.0
     */
    boolean hasBeenEnable(String corpid, String config, String positiveNumber, Long formId) throws XbbException;

    /**
     * 获取表单的配置
     * @param config
     * @param corpid
     * @param formId
     * @param saasMark
     * @param businessType
     * @return
     */
    FormConfigEntity getByConfig(String config, String corpid, Long formId, Integer saasMark, Integer businessType);

    /**
     * 获取表单的配置
     * @param config
     * @param corpid
     * @param formId
     * @param saasMark
     * @param businessType
     * @return
     */
    String getConfigValueByRedis(String config, String corpid, Long formId, Integer saasMark, Integer businessType, String defaultValue);


    Integer save(String config, String corpid, Long formId, Integer saasMark, Integer businessType, String value) throws XbbException;
}
